<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加出版社</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f7fc;
            margin: 0;
            padding: 0;
        }

        .AddForm {
            background-color: #ffffff;
            width: 100%;
            max-width: 500px;
            margin: 50px auto;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        h1 {
            text-align: center;
            font-size: 24px;
            color: #333;
            margin-bottom: 20px;
        }

        .form-group {
            margin-bottom: 12px;
            display: flex;
            align-items: center; 
            justify-content: flex-start;
        }

        label {
            font-size: 16px;
            color: #555;
            text-align: left;
            width: 100px;
            margin-right: 10px; 
        }

        input {
            width: 100%; 
            padding: 8px;
            font-size: 16px;
            border: 1px solid #ddd;
            border-radius: 5px;
            box-sizing: border-box;
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
        }

            input:focus {
                border-color: #007bff;
                box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
                outline: none;
            }

        .btn {
            display: flex;
            justify-content: center;
        }

        button {
            padding: 12px 20px;
            background-color: #007bff;
            color: white;
            font-size: 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

            button:hover {
                background-color: #0056b3;
            }
        .message {
            text-align: center;
            font-size: 16px;
            color: green;
            margin-top: 15px;
        }

        .error {
            text-align: center;
            font-size: 16px;
            color: red;
            margin-top: 15px;
        }
        .popup {
            position: fixed;
            top: -100px; 
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            width: 300px;
            padding: 20px;
            background-color: #fff;
            border-radius: 10px;
            color: #333;
            text-align: center;
            font-size: 16px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            z-index: 10000;
            transition: all 0.5s ease-out;
        }

        .popup-message {
            font-size: 18px;
            font-weight: bold;
        }

        .popup-success {
            background-color: #4CAF50; 
            color: white;
        }

        .popup-failure {
            background-color: #f44336; 
            color: white;
        }

        .popup-show {
            top: 20px; 
            opacity: 1; 
        }

        .popup-hide {
            top: -100px; 
            opacity: 0; 
        }

        /* 首页按钮 */
        .button-container {
            background-color: red;
            border-radius: 5px;
            width: fit-content;
            text-align: center;
        }

            .button-container:hover {
                background-color: darkred;
                transition: background-color 0.3s ease;
            }

        .add-btn {
            padding: 6px 12px;
            font-size: 14px;
            background-color: transparent;
            border: none;
            cursor: pointer;
            border-radius: 8px;
        }

            .add-btn:hover {
                background-color: darkred;
                color: white;
            }

            .add-btn:focus {
                outline: none;
                background-color: darkred;
            }

            .add-btn:active {
                background-color: darkred;
                color: white;
            }
    </style>
</head>

<body>
    @*弹窗*@
    <div id="popup" class="popup">
        <div id="popupMessage" class="popup-message"></div>
    </div>
    @{
        var message = ViewBag.Message as string;
    }
    <div class="AddForm">
        <h1>添加出版社表单</h1>
        @using (Html.BeginForm("AddPublisher", "Home", FormMethod.Post))
        {
        <div class="form-group">
            <label for="publisher_num">编号：</label>
            <input type="number" id="publisher_num" name="publisher_num" required placeholder="请输入编号">
        </div>
        <div class="form-group">
            <label for="publisher_name">名称：</label>
            <input type="text" id="publisher_name" name="publisher_name" required placeholder="请输入出版社名称">
        </div>
        <div class="form-group">
            <label for="publisher_contact">联系人：</label>
            <input type="text" id="publisher_contact" name="publisher_contact" required placeholder="请输入联系人姓名">
        </div>
        <div class="form-group">
            <label for="publisher_place">出版地：</label>
            <input type="text" id="publisher_place" name="publisher_place" required placeholder="请输入出版地">
        </div>
        <div class="btn">
            <button type="submit">提交</button>
        </div>
            <div class="button-container">
                <button type="button" class="add-btn" onclick="window.location.href='@Url.Action("PublisherIndex", "Home")'">返回列表首页</button>
            </div>
        <div class="message">@message</div>
        }
    </div>
    <script>
        var isLoginSuccess = '@ViewBag.IsSuccess'.toLowerCase();

        function hidePopup() {
            var popup = document.getElementById("popup");
            popup.classList.remove("popup-show");
            popup.classList.add("popup-hide");
        }

        function showPopup(status) {
            var popup = document.getElementById("popup");
            var message = document.getElementById("popupMessage");

            if (status === 'success') {
                message.textContent = "添加成功";
                popup.className = "popup popup-success";
            } else if (status === 'failure') {
                message.textContent = "添加失败";
                popup.className = "popup popup-failure";
            }

            hidePopup();
            setTimeout(function () {
                popup.style.display = 'block';
                popup.classList.remove("popup-hide");
                popup.classList.add("popup-show");
            }, 500);

            setTimeout(function () {
                popup.classList.remove("popup-show");
                popup.classList.add("popup-hide");
            }, 2050);

            setTimeout(function () {
                popup.style.display = 'none';
                popup.classList.remove("popup-hide");
            }, 2550);
        }

        if (isLoginSuccess === 'true') {
            showPopup('success');
        } else if (isLoginSuccess === 'false') {
            showPopup('failure');
        }
    </script>
</body>

</html>
